﻿
Imports System.Data
Imports System.Data.SqlClient
Imports CondorTravel.BE
Imports CondorTravelUTIL.DL

Public Class ClienteDALC

    Public Function ListaCliente(ByVal objClienteBE As ClienteBE) As List(Of ClienteBE)

        Dim sqlListar As String
        Dim objListaCliente As New List(Of ClienteBE)
        Dim objCliBE As ClienteBE = Nothing
        Dim arrSqlParameter(0) As SqlParameter
        Dim ds As DataSet
        Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim blnExito As Boolean
        Dim strMensaje As String = String.Empty
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_ClienteList"

            arrSqlParameter(0) = New SqlParameter("@C_NOM", System.Data.SqlDbType.VarChar)
            arrSqlParameter(0).Value = objClienteBE.NomCLi
            objListaCliente = New List(Of ClienteBE)()


            ds = objDatos.DevuelveDataSet(sqlListar, blnExito, strMensaje, arrSqlParameter)
            dt = ds.Tables(0)

            If dt.Rows.Count > 0 Then

                While intI < dt.Rows.Count
                    objCliBE = New ClienteBE()
                    objCliBE.NomCLi = dt.Rows(intI).ItemArray(0).ToString
                    objCliBE.Ruc = dt.Rows(intI).ItemArray(1).ToString
                    intI = intI + 1

                    objListaCliente.Add(objCliBE)
                End While
            End If
        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objListaCliente
    End Function
End Class
